package spindles.api.domain;

public enum CutoffFrequency {
	
	// 3db, 6-21 Hz, 256 Hz
	CUTOFF_6_21_FREQ_256_HZ(new double[]{0.0398 , 0.1715},
			"3 db, 6-21 Hz eeg: "),
	// 3db, 6-21 Hz, 512 Hz
	CUTOFF_6_21_FREQ_512_HZ(new double[]{0.01585, 0.08957},
			"3 db, 6-21 Hz eeg: "),
	// 3db, 10.5-16 Hz, 256 Hz
	CUTOFF_10_5_16_FREQ_256_HZ(new double[]{0.0746 , 0.13235},
			"3 db, 10.5-16 Hz eeg: "),
	// 3db, 10.5-16 Hz, 512 Hz
	CUTOFF_10_5_16_FREQ_512_HZ(new double[]{0.0385, 0.0651}, 
			"3 db, 10.5-16 Hz eeg: "),
	ALL_FREQ(new double[]{0.0}, "Raw eeg: ");
	
	
	private double[] Wn = new double[2];
	
	private String label;
	
	CutoffFrequency(double[] Wn, String label) {
		this.Wn = Wn;
		this.label = label;
	}	

	public double[] getValue(){
		return Wn;
	}
	
	public String getLabel(){
		return label;
	}
	
	public static CutoffFrequency getCutoffFreq_6_21(SamplingRate sr){
		switch(sr){
		case SR256:
			return CutoffFrequency.CUTOFF_6_21_FREQ_256_HZ;			
		case SR512:
			return CutoffFrequency.CUTOFF_6_21_FREQ_512_HZ;
		default:
			return null;
		}
	}
	
	public static CutoffFrequency getCutoffFreq(CutoffFrequency currFreq, SamplingRate sr){
		CutoffFrequency result = null;
		
		if(sr == SamplingRate.SR256 && currFreq == CUTOFF_10_5_16_FREQ_512_HZ){
			result = CUTOFF_10_5_16_FREQ_256_HZ;
		} else if(sr == SamplingRate.SR256 && currFreq == CUTOFF_6_21_FREQ_512_HZ){
			result = CUTOFF_6_21_FREQ_256_HZ;
		} else if(sr == SamplingRate.SR512 && currFreq == CUTOFF_10_5_16_FREQ_256_HZ){
			result = CUTOFF_10_5_16_FREQ_512_HZ;
		} else if(sr == SamplingRate.SR512 && currFreq == CUTOFF_6_21_FREQ_256_HZ){
			result = CUTOFF_6_21_FREQ_512_HZ;
		} else {
			result = currFreq;
		}
		
		return result;
	}
	
	public static CutoffFrequency getCutoffFreq(SamplingRate sr){
		switch(sr){
		case SR256:
			return CutoffFrequency.CUTOFF_10_5_16_FREQ_256_HZ;			
		case SR512:
			return CutoffFrequency.CUTOFF_10_5_16_FREQ_512_HZ;
		default:
			return null;
		}		
	}

}
